/*
 * The MiniQt Library
 *
 * Copyright (C) 1999 Sandro Sigala <ssigala@globalnet.it>
 */

#ifndef QOBJECT_H
#define QOBJECT_H

#include "qminiqt.h"
#include "qlist.h"
#include "qnamespace.h"

struct QObjectPrivate;

class QObject;

typedef void (QObject::*QMember)();
typedef QList<QObject> QObjectList;

class QMetaObjectCheck {
public:
	QMetaObjectCheck() { init = FALSE; }
	~QMetaObjectCheck() {}

	bool wasInitialized() { return init; }
	void initialize() { init = TRUE; }

private:
	bool init;
};

class QObject : public Qt {
public:
	QObject(QObject *parent = 0, const char *name = 0);
	virtual ~QObject();

	const char *name() const;
	const char *name(char *defname) const;
	virtual void setName(const char *name);

	QObject *parent() const;
	const QObjectList *children();
	virtual bool isWidgetType() const;

	virtual const char *className() const;

	static void connect(QObject *src, const char *signame,
		            QObject *dest, const char *slotname);

protected:
	virtual void initMetaObject();
	void registerSignal(const char *signame);
	void calledSignal(const char *signame);
	void registerSlot(const char *slotname, QObject *dest, QMember member);
	void calledSlot(const char *slotname);

private:
	QObjectPrivate *d;

	void registerChild(QObject *child);
	void unregisterChild(QObject *child);
	void deleteChilds();

	void addConnection(const char *signame, QObject *dest, const char *slotname);
};

#endif // !QOBJECT_H
